package com.company.class5;

/**
 * @Classname Dog
 * @Description 类型说明
 * @Date 2022/4/24 17:21
 * @Created by zbw
 */

public class Dog {

    // 三种叫声
    public static final String LITTLE_BARK = "呜呜";
    public static final String MIDDLE_BARK = "汪汪";
    public static final String OLD_BARK = "嗷嗷";

    //年龄
    public int age = 0;

    //长大
    //可以指定长大的岁数
    public void grow(int growAge){
        age += growAge;
    }
    //不传参，就默认长一岁
    public void grow(){
        age++;
    }

    //叫
    public void bark(int growAge){
        //先长大
        grow(growAge);
        System.out.println("现在"+age+"岁了");
        //判断年龄
        if(age < 2){
            System.out.println("小狗"+LITTLE_BARK+"叫");
        }else if(age < 10){
            System.out.println("大狗"+MIDDLE_BARK+"叫");
        }else if(age <= 12){
            System.out.println("老狗"+OLD_BARK+"叫");
        }
    }

    //叫
    public void bark(){
        //先长大
        grow(1);
        //判断年龄
        if(age < 2){
            System.out.println("小狗"+LITTLE_BARK+"叫");
        }else if(age < 10){
            System.out.println("大狗"+MIDDLE_BARK+"叫");
        }else if(age <= 12){
            System.out.println("老狗"+OLD_BARK+"叫");
        }
    }
}
